package com.akkainaction.remote.rpc.server;

import akka.actor.ActorSelection;
import akka.actor.UntypedActor;

public class UserClientActor extends UntypedActor {

    @Override
    public void onReceive(Object msg) throws Exception {
        if (msg instanceof String) {
            System.out.println(msg);
            if ("talk".equals(msg)) {
                //这里的地址要和server端发布的地址相同 akka.tcp://sys@127.0.0.1:2251
                //远程actor的名称也一定要和远程的一致userServerActor
                ActorSelection actorSelection = getContext().actorSelection("akka.tcp://sys@127.0.0.1:2251/user/userServerActor");
                actorSelection.tell("Hello UserServerActor......",getSelf());
            }
        }else {
            unhandled(msg);
        }
    }
}
